<template>
  <div class="search-history">
    <van-cell title="历史记录">
      <div v-if="isShow">
        <span @click="onSearchRemove('', 'all')">全部删除</span>&nbsp;&nbsp;
        <span @click="isShow = false">完成</span>
      </div>
      <van-icon v-else @click="isShow = true" name="delete" />
    </van-cell>
    <van-cell
      v-for="(history, index) in Historys"
      @click="onSearchRemove(history, index)"
      :key="index"
      :title="history"
    >
      <van-icon v-show="isShow" name="close" />
    </van-cell>
  </div>
</template>

<script>
export default {
  name: 'SearchHistory',
  components: {},
  props: {
    Historys: {
      type: Array
    }
  },
  data() {
    return { isShow: false }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onSearchRemove(history, index) {
      if (this.isShow) {
        console.log(index, 'asdf')
        this.$emit('removeHistory', index)
      } else {
        console.log(history)
        this.$emit('searchs', history)
      }
    }
  }
}
</script>

<style scoped lang="less"></style>
